package cn.edu.xmut.chen.zhlg.zhlg.vacancy.mapper;

import cn.edu.xmut.chen.zhlg.zhlg.vacancy.entity.Collect;
import cn.edu.xmut.chen.zhlg.zhlg.vacancy.result.CollectResult;
import cn.edu.xmut.chen.zhlg.zhlg.vacancy.result.VacancyPageResult;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CollectMapper extends BaseMapper<Collect> {
    @Select("<script>" +
            "SELECT collect.id, v.id as jobId, v.vacancy_name as vacancyName, c.address, v.salary, v.create_time, " +
            "c.company_name AS companyName, c.`condition` AS companyCondition, c.number AS companyNumber, " +
            "c.industry AS companyIndustry, c.pic AS companyPic, " +
            "u.nick_name AS posterName, u.pic AS posterPic " +
            "FROM tb_collect collect " +
            "LEFT JOIN tb_vacancy v ON v.id = collect.job_id " +
            "LEFT JOIN tb_company c ON v.company_id = c.id " +
            "LEFT JOIN tb_user u ON v.poster_id = u.id " +
            "WHERE v.delete_flag = 'NOT_DELETE' " +
            "AND collect.user_id = #{userId} " +
            "ORDER BY v.create_time DESC " +
            "</script>")
    Page<CollectResult> pageSearch(Page<CollectResult> page, @Param("userId") String userId);
} 